<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <title>白名单</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/layuiadmin/style/admin.css" media="all">
</head>
<body>

<div class="layui-card layadmin-header">
    <div class="layui-breadcrumb" lay-filter="breadcrumb">
        <a lay-href="">主页</a>
        <a><cite>组件</cite></a>
        <a><cite>数据表格</cite></a>
        <a><cite>开启分页</cite></a>
    </div>
</div>

<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div id="userlist" style="width: 100%;height: 400px"></div>
            </div>
        </div>
        <div class="layui-col-md6">
            <div class="layui-card">
                <div id="userlist1" style="width: 100%;height: 400px"></div>
            </div>
        </div>
        <div class="layui-col-md6">
            <div class="layui-card">
                <div id="userlist2" style="width: 100%;height: 400px"></div>
            </div>
        </div>
    </div>
</div>
<script src="/layuiadmin/layui/layui.js"></script>
<script src="/jquery/echarts.js"></script>
<script>
    layui.config({
        base: '/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'table', 'laydate', "layer", 'upload'], function () {
        var admin = layui.admin
            , table = layui.table,
            upload = layui.upload,
            layer = layui.layer,
            form = layui.form,
            $ = layui.$,
            laydate = layui.laydate

        $.ajax({
            type: 'get',
            url: '/user/staByCollege',
            success: function (res) {
                //res.data
                var div = echarts.init($("#userlist")[0])
                var option = {
                    title: {
                        text: '学生统计'
                    },
                    tooltip: {},
                    legend: {
                        data: ['总数','困难人数']
                    },
                    xAxis: {
                        data: []
                    },
                    yAxis: {},
                    series: [
                        {
                            name: '总数',
                            type: 'bar',
                            data: []
                        },
                        {
                            name: '困难人数',
                            type: 'bar',
                            data: []
                        }
                    ],
                    emphasis: {
                        itemStyle: {
                            // 高亮时点的颜色。
                            color: 'red'
                        }
                    }
                };
                $(res.data.knrd).each(function (index, item) {
                    option.xAxis.data.push({value: item.name,textStyle: {color: 'red',fontFamily: '楷体'}})
                    option.series[1].data.push(item.count)
                })
                $(res.data.all).each(function (index, item) {
                    option.series[0].data.push(item.count)
                })

                div.setOption(option)

                var div1 = echarts.init($("#userlist1")[0])
                var op = {
                    tooltip: {
                        trigger: 'item'
                    },
                    legend: {
                        type: 'scroll',
                        orient: 'vertical',
                        left: '5px'
                    },
                    name: '学生统计',
                    series: [
                        {
                            type: 'pie',
                            data: []
                        }
                    ]
                }
                $(res.data.knrd).each(function (index,item) {
                    op.series[0].data.push({name: item.name, value: item.count})
                })
                div1.setOption(op)

                var div2 = echarts.init($("#userlist2")[0])
                var option2 = {
                    title: {
                        text: '学生统计'
                    },
                    tooltip: {},
                    legend: {
                        data: ['总数','困难人数']
                    },
                    xAxis: {
                        data: []
                    },
                    yAxis: {},
                    series: [
                        {
                            name: '总数',
                            type: 'line',
                            data: []
                        },
                        {
                            name: '困难人数',
                            type: 'line',
                            data: []
                        }
                    ],
                    emphasis: {
                        itemStyle: {
                            // 高亮时点的颜色。
                            color: 'red'
                        }
                    }
                };
                $(res.data.knrd).each(function (index, item) {
                    option2.xAxis.data.push({value: item.name,textStyle: {color: 'red',fontFamily: '楷体'}})
                    option2.series[1].data.push(item.count)
                })
                $(res.data.all).each(function (index, item) {
                    option2.series[0].data.push(item.count)
                })

                div2.setOption(option2)
            }
        })


        //配置这个div

        //将配置设置进div

    });
</script>
</body>
</html>